library(ggplot2)
library(gridExtra)
library(haven)


# Figure 8.4
df.mtf <- read_dta("C:/Users/Robert Allred/Documents/Duke/Civ_Mil_Appendix/Data/MTF_Aggregate.dta")


# Line plot without points
gp1 <- ggplot(data=df.mtf, aes(x=var1))+
  geom_line(aes(y=good2,linetype="Good"),
            size=1.03)+
  geom_line(aes(y=fair2,linetype="Fair"),
            size=1.03)+
  geom_line(aes(y=poor2,linetype="Poor"),
            size=1.03)+
  scale_y_continuous(limits=c(0,25))+
  scale_x_continuous(limits=c(1995,2019.5))+
  scale_linetype_manual(breaks=c("Good","Fair","Poor"),values = c(1,2,3))+
  ggtitle("Definitely Will Join the Military")+
  xlab("\nYear")+
  ylab("\n% of Seniors Saying They Definitely Will Join\n")+
  theme(panel.grid = element_blank(), panel.background = element_blank(),
        panel.border = element_rect(fill=NA),
        text = element_text(size=14), legend.position = "bottom", 
        legend.title = element_blank(),
        plot.title = element_text(hjust = 0.5))

gp2 <- ggplot(data=df.mtf, aes(x=var1))+
  geom_line(aes(y=good,linetype="Good"),
            size=1.03)+
  geom_line(aes(y=fair,linetype="Fair"),
            size=1.03)+
  geom_line(aes(y=poor,linetype="Poor"),
            size=1.03)+
  scale_y_continuous(limits=c(0,25))+
  scale_x_continuous(limits=c(1995,2019.5))+
  scale_linetype_manual(breaks=c("Good","Fair","Poor"),values = c(1,2,3))+
  ggtitle("Probably Will Join the Military")+
  xlab("\nYear")+
  ylab("\n% of Seniors Saying They Probably Will Join\n")+
  theme(panel.grid = element_blank(), panel.background = element_blank(),
        panel.border = element_rect(fill=NA),
        text = element_text(size=14), legend.position = "bottom", 
        legend.title = element_blank(),
        plot.title = element_text(hjust = 0.5))

grid.arrange(gp1,gp2,ncol=2)
